#include "StdAfx.h"
#include "FMDBParameter.h"
#include "FMDBTOOLS.h"

//note:here VarValueArray is a void* array, this is usful when caller want to run a series of DML statement
// for example if caller want to update or insert a set of record, the SQL statement could be the same except binding variable.
// use parameter array, we can get best performace for batch update,insert,etc
FMDBParameter::FMDBParameter( TCHAR *VarName, int *VarValueArray )
{
	m_pstrVarName=NULL;
	DBTOOLS::CopyPropertyValue(&m_pstrVarName,VarName);
	m_VarValue=VarValueArray;
	
	m_VarDataType=SQLT_INT;
}

FMDBParameter::FMDBParameter( TCHAR *VarName,TCHAR *VarValueArray )
{
	m_pstrVarName=NULL;
	DBTOOLS::CopyPropertyValue(&m_pstrVarName,VarName);
	m_VarValue=VarValueArray;
	
	m_VarDataType=SQLT_STR;
}

FMDBParameter::FMDBParameter( TCHAR *VarName,long *VarValueArray )
{
	m_pstrVarName=NULL;
	DBTOOLS::CopyPropertyValue(&m_pstrVarName,VarName);
	m_VarValue=VarValueArray;

	m_VarDataType=SQLT_INT;
}


FMDBParameter::~FMDBParameter(void)
{
}


void FMDBParameters::AddParam( FMDBParameter *Param )
{
	//only check the para name should not be NULL
	if (Param)
	{
		if(Param->GetVarName())
		{
			m_vParam.push_back(Param);
		}
	}
}

void FMDBParameters::AddOCIIOVParam( FMDBIOVParameter *Param )
{
	//only check the para name should not be NULL
	if (Param)
	{		
		m_vIOVParam.push_back(Param);		
	}
}

void FMDBParameters::AddCursorParam( FMDBCursorParameter *Param )
{
	//only check the para name should not be NULL
	if (Param)
	{		
		m_vCursorParam.push_back(Param);		
	}
}

FMDBIOVParameter::FMDBIOVParameter( TCHAR *VarName,OCIIOV *VarValueArray,ub4 ArraySize,ub2 VarOraDataType )
{
	m_pstrVarName=NULL;
	DBTOOLS::CopyPropertyValue(&m_pstrVarName,VarName);
	m_VarValue=VarValueArray;
	m_ValueArraySize=ArraySize;
	m_VarDataType=VarOraDataType;
	//note:here I do not keep varValue,so the caller must keep the value available till finish the executing.
}

FMDBCursorParameter::FMDBCursorParameter( TCHAR *VarName,OCIStmt *VarValue,FMDBRecordSet *Rs )
{
	m_pstrVarName=NULL;
	DBTOOLS::CopyPropertyValue(&m_pstrVarName,VarName);
	m_VarValue=VarValue;
	m_pRs=Rs;
}

FMDBCursorParameter::~FMDBCursorParameter( void )
{

}
